package main

import (
	"fmt"
	"net/http"
	"io"
	"github.com/gorilla/mux"
	"html/template"
	"os"
	"encoding/json"
)

type data struct {
	title string
}

func main() {
testMap()

}




/**
gorilla/mux 示例
 */
func severHttps() {
	ru := mux.NewRouter()
	ru.HandleFunc("/api/{name:[a-zA-Z]+}", func(writer http.ResponseWriter, request *http.Request) {
		io.WriteString(writer, "test")
		cookies:=request.Cookies()
		fmt.Println(cookies)
		fmt.Println(mux.Vars(request)["name"])
		request.URL.Path = "123"
		println(request.URL.Path)
	})
	ru.HandleFunc(string("dwadw"), func(writer http.ResponseWriter, request *http.Request) {

	})
	http.Handle("/", ru)
	http.ListenAndServe(":8090", ru)
}

/**
html/template模板例子
 */
func stringUtil() {
	var a string = "43434343434"
	fmt.Println(a)
}

func parseTemplate() {
	data := data{"wangmeng"}
	a, _ := template.ParseFiles("./template.html")
	a.Execute(os.Stdout, data)
}


func testMap() {
	countryCapitalMap := make(map[string]string)
	countryCapitalMap["wangmeng"] = "dawdaw"
	var res=data{title:"wangmeng"}
	res,err:=json.Marshal(res)
	if err==nil {
		fmt.Println(string(res))
	}

}